<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		<meta charset="utf-8" />
		<title></title>
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="static/css/bootstrap.min.css" />
		<link rel="stylesheet" href="static/css/bootstrap-responsive.min.css" />
		<link rel="stylesheet" href="static/css/font-awesome.min.css" />
		<link rel="stylesheet" href="static/css/chosen.css" />
		<link rel="stylesheet" href="static/css/ace.min.css" />
		<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
		<link rel="stylesheet" href="static/css/ace-skins.min.css" />
		<link rel="stylesheet" href="static/css/date/bootstrap-datetimepicker.css" /><!-- 日期框 -->
		<link rel="stylesheet" href="static/css/date/bootstrap-datetimepicker.min.css" /><!-- 日期框 -->
		<script type="text/javascript">
			//保存
			function save(){
				if($("#promotion_name").val()==""){
					$("#promotion_name").tips({
						side:3,
			            msg:'输入推广人员名称',
			            bg:'#AE81FF',
			            time:3
			        });
					$("#promotion_name").focus();
					return false;
				}

				var target_object = $("#target_object_current").val();
				if(target_object == 2){
					var str = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++){
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  }
					}
					
					$("#org_id").val(str);
					
					if(str==''){
						bootbox.dialog("您需要选择一个商户，请先选择一个商户!", 
							[
							  {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback": function() {
									//Example.show("great success");
									}
								}
							 ]
						);
						return false;
					}
				}
				
				$("#weixinPomotionForm").submit();
				$("#centerOfMainFrame").hide();
				$("#centerOfMainFrame2").show();
			}
		</script>
	</head>
<body onload="verifyMessageType();">
	<div id="organ_part_id" style="display: none;">
			<!-- 检索  -->
			<form action="weixinPomotion/goAddWeixinPomotion.do" method="post" name="organInfoForm" id="organInfoForm">
			<input type="hidden" name="target_object" id="target_object" value="${pageData.target_object }"/>
			<input type="hidden" name="target_object_act" id="target_object_act" value="2"/>
			<table id="table_report" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th class="center">
							<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
						</th>
						<th>序号</th>
						<th>商户ID</th>
						<th>商户名称</th>
					</tr>
				</thead>
										
				<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='radio' name='ids' value="${var.id }" id="choose_${var.id }"/><span class="lbl"></span></label>
								</td>
								<td class='center' style="width: 30px;">${vs.index+1}</td>
								<td>${var.id }</td>
								<td>${var.organ_name }</td>
							</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="11" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
			</table>
			
		<div class="page-header position-relative">
			<table style="width:100%;">
				<tr>
					<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
				</tr>
			</table>
		</div>
		</form>
	</div>
	
	<form action="<%=basePath%>/weixinPomotion/saveWeixinPomotion.do" name="weixinPomotionForm" id="weixinPomotionForm" method="post" enctype="multipart/form-data">
		<input type="hidden" name="org_id" id="org_id"/>
		<div id="centerOfMainFrame">
			<table>
				<tr>
					<td align="right">推广名称（人员、楼宇、商户）： </td><td><input type="text" name="promotion_name" id="promotion_name" title="推广人员名称" width="600px"/></td>
				</tr>
				<tr>
					<td align="right">二维码类型： </td>
					<td>
						<select class="chzn-select" name="qrcode_type" id="qrcode_type" style="vertical-align:top;width: 600px;">
							<option value="1">临时二维码</option>
							<option value="2">永久二维码</option>
					  	</select>
					</td>
				</tr>
				<tr>
					<td align="right">应用对象： </td>
					<td>
						<select class="chzn-select" name="target_object_current" id="target_object_current" style="vertical-align:top;width: 600px;" onchange="changeOrgMsgType(this.value);">
							<option value="1" <c:if test="${pageData.target_object=='1'}">selected</c:if>>个人</option>
							<option value="2" <c:if test="${pageData.target_object=='2'}">selected</c:if>>商户</option>
							<option value="3" <c:if test="${pageData.target_object=='3'}">selected</c:if>>楼宇、活动、其它</option>
					  	</select>
					</td>
				</tr>
				<tr><td>&nbsp;&nbsp;</td></tr>
				<tr>
					<td style="text-align: center;" colspan="2">
						<a class="btn btn-mini btn-primary" onclick="save();">保存</a>
						<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
					</td>
				</tr>
			</table>
		</div>
		<input type="hidden" name="token" value="${token}" />
		<div id="centerOfMainFrame2" class="center" style="display:none"><br/><br/><br/><br/><img src="static/images/jiazai.gif" /><br/><h4 class="lighter block green"></h4></div>
	</form>
	
	<!-- 引入 -->
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<script type="text/javascript" src="static/js/date/jquery-1.8.3.min.js" charset="UTF-8"></script>
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>
	<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
	<script type="text/javascript" src="static/js/ace.min.js"></script>
	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
	<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="static/js/date/bootstrap-datetimepicker.js" charset="UTF-8"></script>
	<script type="text/javascript" src="static/js/date/bootstrap-datetimepicker.zh-CN.js"></script><!-- 日期框 -->
	<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
	<script type="text/javascript">
	$(top.hangge());
	$(function() {
		//单选框
		$(".chzn-select").chosen(); 
		$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
	});
	
	function changeOrgMsgType(type) {
		if(type==2){
			$("#organ_part_id").css('display', ''); 
		}else{
			$("#organ_part_id").css('display', 'none'); 
		}
	}
	
	function verifyMessageType() {
		var target_object = $("#target_object").val();
		//alert("verifyMessageType: " + message_type);
		if(target_object == 2){
			$("#organ_part_id").css('display', ''); 
		}else{
			$("#organ_part_id").css('display', 'none'); 
		}
	}
	</script>
</body>
</html>